import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {//10
    private static final int[][] DIRECTIONS = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}};
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine().trim());
        String op = br.readLine().trim();
        int direction = 0;
        int x = 0, y = 0;
        int[] directions = new int[n + 1];
        long[] xs = new long[n + 1], ys = new long[n + 1];
        directions[0] = direction;
        xs[0] = x;
        ys[0] = y;
        for (int i = 0; i < n; ++i) {
            char c = op.charAt(i);
            if (c == 'L') {
                direction = (direction + 3) % 4;
            } else if (c == 'R') {
                direction = (direction + 1) % 4;
            }
            x += DIRECTIONS[direction][0];
            y += DIRECTIONS[direction][1];
            directions[i + 1] = direction;
        }
        System.out.println(direction);
    }//err



    public static void main9(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[][] matrix = new int[n][m];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                matrix[i][j] = sc.nextInt();
            }
        }
        int ans = Integer.MIN_VALUE;
        for (int x1 = 0; x1 < n; x1++) {
            for (int y1 = 0; y1 < m; y1++) {
                for (int len = 1; x1 + len < n && y1 + len < m; len++) {
                    int x2 = x1 + len;
                    int y2 = y1 + len;
                    int tmp = 0;
                    for (int y = y1; y <= y2; y++) {
                        tmp += matrix[x1][y];
                    }
                    for (int y = y1; y <= y2; y++) {
                        tmp += matrix[x2][y];
                    }
                    for (int x = x1 + 1; x < x2; x++) {
                        tmp +=matrix[x][y1];
                    }
                    for (int x = x1 + 1; x < x2; x++) {
                        tmp +=matrix[x][y2];
                    }
                    ans = Math.max(ans,  tmp);
                }
            }
        }
        System.out.println(ans);
    }



    public static void main8(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s1 = sc.next();
        String s2 = "LANQIAO";
        int id = 0;
        for (int i = 0; i < s1.length(); i++) {
            if (s1.charAt(i) == s2.charAt(id)) {
                id++;
            }
            if (id == s2.length()) {
                System.out.println("YES");
                return;
            }
        }
        System.out.println("NO");
    }



    public static void main7(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int ans = Integer.MAX_VALUE;
        while (n --> 0) {
            int tmp = sc.nextInt();
            if (tmp % 2 == 0) {
                ans = Math.min(ans, tmp);
            }
        }
        System.out.println(ans);
    }



    public static void main6(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();//输入语句
        System.out.println(2024 % n == 0 ? 2024 / n : (2024 / n) + 1);
    }
}

